package cc.rengu.redp.flowable.domain;

import lombok.Data;

import java.util.List;

/**
 * 和流程图设计器的数据结构一一对应
 *
 * @author xushitang
 */
@Data
public class FlowDesignDrawer {

    private List<Node> nodeList;
    private List<Link> linkList;
    private Attribute attr;
    private Config config;
    private String previewImage; //生成的base64流程图快照
    private String status;
    private List<Object> remarks;

    @Data
    public class Node {
        public final static String NODE_TYPE_START = "start";
        public final static String NODE_TYPE_END = "end";
        public final static String NODE_TYPE_USER = "common";
        public final static String NODE_TYPE_SERVICE = "freedom";
        public final static String NODE_TYPE_EVENT = "event";
        public final static String NODE_TYPE_GATEWAY = "gateway";
        public final static String NODE_TYPE_SUB_FLOW = "child-flow";

        private String type;
        private String nodeName;
        private String icon;
        private String id;
        private Integer height;
        private Integer width;
        private Integer x;
        private Integer y;
        /**
         * 节点自定义参数
         */
        private CustomStartNode customStartNode;
        private CustomUserNode customUserNode;
        private CustomServiceNode customServiceNode;
        /**
         * 监听器配置
         */
        private List<ListenerConfig> listenerConfigs;
    }

    @Data
    public class Link {
        private String type;
        private String id;
        private String sourceId;
        private String targetId;
        private String label;
        private LinkClass cls;
        /**
         * 自定义流转线参数
         */
        private CustomSequenceFlow customSequenceFlow;
        /**
         * 监听器配置
         */
        private List<ListenerConfig> listenerConfigs;

        @Data
        public class LinkClass {
            private String linkType;
            private String linkColor;
            private Integer linkThickness;
        }
    }

    @Data
    public class Attribute {
        private String id;
        private String persistId;
        private String name;
        private String description;
        private CustomProcess customProcess;
    }

    @Data
    public class Config {
        private Boolean showGrid;
        private String showGridText;
        private String showGridIcon;
    }
}
